package com.soft.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.soft.entity.User;
import com.soft.service.UserService;

@RestController
@RequestMapping("/user")
public class UserController {
	@Autowired
	private UserService userService;
	@RequestMapping("/queryAllUser")
	public List<User> queryAll(){
		return userService.queryAll();
	}
	@RequestMapping("/queryByuserAge")
	public List<User> queryByuserAge(String userAge){
		return userService.queryByuserAge(userAge);
	}
	@RequestMapping("/insertOne")
	public String insertOne(String userName,String userAge,String userEmail) {
		int num = userService.insertOne(userName, userAge,userEmail);
		if(num ==1) {
			return userName+"添加成功";
		}else 
		{
			return userName+"添加失败";
		}
	}
	@RequestMapping("/deleteOne")
	public String deleteById(Long userId) {
		int num = userService.deleteById(userId);
		if(num ==1) {
			return userId+"删除成功";
		}else 
		{
			return userId+"删除失败";
		}
	}
}
